<link href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}" rel="stylesheet">
<div class="pageContent" style="padding: 5px">
    <input id="menuCode" type="hidden">
    <div class="per-docContact fn-pos-rel">
<div class="fn-left fn-pos-rel">
<div class="per-docContact-tab">
</div>
    <div class="contactList">
        <div id="lefttree" style="width: 100%;height: 100%;overflow: auto;">
            <ul id="tree" class="tree treeFolder treeCheck expand" oncheck="oncheck">
                <#list treeList as tree>
                <li><a tvalue="${tree.menuCode}" tname="${tree.menuText}">${tree.menuText}</a> <#if tree.children?? &&tree.children?size gt 0>
                    <ul><@bpTree children=tree.children />
                    </ul> </#if> </#list>
            </ul>
        </div>
    </div>
    </div>
    <div class="contactArrow"></div>

    <div layoutH="60" style="margin-right: 5px; float: right; display: block; width: 280px; overflow: auto; background: #fff">
    <div class="per-docContact-listtitle">
          <span class="fn-left"><@label key="selected.C">已选择</@label>(<span id="selected_count">0</span>)：</span>
          <span class="fn-right linkblue"><a onclick="cl()"><@label key="clear.C">清空</@label></a></span>
      </div>
    <div class="per-docContact-list">

    <div  class="contactSelected">
    <ul id="selected">

    </ul>
    </div>
    
    </div>
    </div>
    </div>
</div>

<div class="formBar">
        <ul>
            <li>
                <a id="ok" href="javascript:" style="margin-right: 10px;"  class="buttonActive" onclick="cc()"><span><@label key="ok.B">确定</@label></span></a>
            
                    
                </li>
            <li>
            <div class="buttonActive" >
                        <div class="buttonContent" >
                            <button class="close" type="button"><@label key="close.B">关闭</@label></button>
                        </div>
                    </div>
            </li>
        
        </ul>
    </div>




<#macro bpTree children> <#if children?? && children?size gt 0> <#list children as child>
<li><a tvalue="${child.menuCode}" tname="${child.menuText}">${child.menuText}</a> <#if child.children?? &&child.children?size gt 0>
    <ul><@bpTree children=child.children />
    </ul> </#if> </#list> </#if> </#macro>
    
    <script type="text/javascript">

function oncheck(){    
     var id = "";
     var name="";
     var str = "";
     var jsonstr="";
     $('#lefttree input[type="checkbox"]').not("input:checked",$.pdialog.getCurrent()).each(function (i, e) {
         var my_element = $('#'+e.value,$.pdialog.getCurrent());
         if(my_element.length>0)
         {
             my_element.remove();
         }
     });
     var count=0;

      $('#lefttree div[class="ckbox indeterminate"]',$.pdialog.getCurrent()).each(function (i, e) {
          var obj = $(e);
          var a= obj.find("input[type='checkbox']",$.pdialog.getCurrent());
          a.attr("checked","checked");
         });
      
     $('#lefttree input[type="checkbox"]:checked',$.pdialog.getCurrent()).each(function (i, e) {
         var idArr = id.split(',');
         if(jQuery.inArray(e.value, idArr)==-1)
         {
         count++;
         var my_element = $('#'+e.value,$.pdialog.getCurrent());
         if(my_element.length==0)
         {
             str += "<li id="+e.value+"><span class='contactList-filephoto'></span><span class='contactName'>"+e.name+"</span><span onclick=del('"+e.value+"') class='deleteInfo'></span></li>";
            
         }
         id+=e.value+",";
         name+=e.name+",";
         }
     });
     
     
     id = id.substring(0,id.length - 1);
     name=name.substring(0,name.length - 1).encode();
     jsonstr+="{id:'"+id+"', name:'"+name+"'}";
     $("#selected",$.pdialog.getCurrent()).append(str);
     if(count>0)
         {
     $("#ok",$.pdialog.getCurrent()).attr("onclick", "$.bringBack("+jsonstr+")");
         }
     else
         {
         $("#ok",$.pdialog.getCurrent()).attr("onclick", "cc()");
         }
     $('#selected_count',$.pdialog.getCurrent()).html(count);
     initUI($("#ok",$.pdialog.getCurrent()));
     
}

function cc(){
    alertMsg.warn('<@label key="selectAuth.M">请勾选权限！</@label>')
}

function del(a){
    $("#"+a,$.pdialog.getCurrent()).remove();
     $("#lefttree input[value='"+a+"']:checked",$.pdialog.getCurrent()).each(function (i, e) {
         var obj = $(e);
           var a= obj.parent().parent().find("a[tvalue="+e.value+"]",$.pdialog.getCurrent());
           a.click();
     });
    oncheck();
    
}



function cl()
{
     $('#selected li').each(function (i, e) {
     e.remove();
     $("#lefttree input[value='"+e.id+"']:checked",$.pdialog.getCurrent()).each(function (j, n) {
         var obj = $(n);
           var a= obj.parent().parent().find("a[tvalue="+n.value+"]",$.pdialog.getCurrent());
           a.click();
     });
    
     });
    oncheck();
}




</script>